<meta http-equiv="Content-Type" content="text/html"; charset="utf-8 "/>
<!-- 商品规格 -->
<#setting url_escaping_charset='utf-8'>
<!--检测当前会员是否登录-->
<#assign memberIsloginInfoTag = newTag('memberIsLoginTag') />
<#assign isLogin = memberIsloginInfoTag()!''/>

<input type="hidden" value="1" name="havespec" />
<div class="goods-spec" id="goods-spec">
	<h4 class="spec-tip"></h4>
	<#if groupbuyIsOn=="ON">
		<!-- 创建商品规格标签 -->
		<#assign goodsSpecTag = newTag("groupBuyGoodsSpecTag") >
		<!-- 调用商品规格标签 -->
		<#assign goodsSpace = goodsSpecTag()!'' >
	<#else>
		<!-- 创建商品规格标签 -->
		<#assign goodsSpecTag = newTag("goodsSpecTag") >
		<!-- 调用商品规格标签 -->
		<#assign goodsSpace = goodsSpecTag()!'' >
	</#if>
	<!-- 规格列表 -->
	<#list goodsSpace.specList as spec>
		<table width="100%" class="spec-item">
			<tbody>
				<tr>
					<td style="width: 10%; white-space: nowrap;"><span><em>${spec.spec_name}</em>：</span></td>
					<td style="padding-left: 15px;">
		 				<ul>
							<#list spec.valueList as val  >
								<#if spec.spec_type==0>
									<li>
										<a specid="${spec.spec_id}" specvid="${val.spec_value_id}"  href="javascript:;" class="<#if val_index == 0>selected</#if>" title="${val.spec_value!''}">
											${val.spec_value!''}
                                            <input type="hidden" name="specs" value="${val.spec_value!''}"/>
											<span></span>
										</a>
									</li>
								</#if>
								<#if spec.spec_type==1>
									<li>
										<a specid="${spec.spec_id}" specvid="${val.spec_value_id}"  href="javascript:;" class="<#if val_index == 0>selected</#if>" title="${val.spec_value!''}" >
											${val.spec_value!''}
                                            <input type="hidden" name="specs" value="${val.spec_value!''}"/>
											<span></span>
											<!-- <@image  title="${val.spec_value!''}" alt="${val.spec_value!''}" src="${val.spec_image!''}" /> -->
										</a>
									</li>
								</#if>				
							</#list>
						</ul>
					</td>
				</tr>
			</tbody>
		</table>
	</#list>
</div>
<!-- 商品购买 -->
<div class="rer-quantity" style="margin-top:5px;margin-bottom:0" id="saveDate">
	<label>订购数量：</label>
	<div id="num" class="Numinput"></div>	
	 <span class="delivery last-pro-duct-num">仅剩 <span class="enable_store">${goods.enable_store}</span> 件，抓紧时间购买哦！</span>					
</div>
<div class="btn-box" style="margin-top:5px;">
	<input type="hidden" id="isLogin" value="${isLogin?string}">
	<input type="hidden" value="${goods.goods_id}" id="gooid" >
	<input type="hidden" name="productid" id="productid"  />
	<div class="btn-div">
		<input type="button" class="white-btn" value="暂无库存" <#if goods.store gt 0>style="display:none"</#if> 	goodsid="${goods.goods_id}"/>
	</div>
	<#if goods.type_id==69||goods.type_id==70>
		<div class="btn-div">
			<input type="button" class="yellow-btn" value="立即投保"  id="insuranceNow"/>
		</div>
	<#else>
		<div class="btn">
			<input type="button" class="buynow-btn green-btn" value="立即购买"  id="buyNow"/>
		</div>
		<div class="btn-div">
			<input type="button" class="addtocart-btn yellow-btn" value="加入购物车"  id="addbutton" <#if goods.store ==  0 || (goods.isvirtual?exists &&goods.isvirtual==1) >style="display:none"</#if>/>
		</div>
	</#if>

	<div class="btn-div">
		<a href="javascript:void(0);" class="favorite" goodsid="${goods.goods_id}"></a>
	</div>
</div>
<div id="login_tip" style="display:none">
	<div class="message" style="width: 300px;height:150px;">
		您当前是游客身份，游客身份不能购买商品！<br><br>
	</div>
	<div class="button-wrapper">
		<div class="btn-div">
			<input type="button" class="small-green to-login-btn go-next-button" value="马上登录">
		</div>

		<div class="btn-div">
			<input type="button" class="small-yellow to-checkout-btn go-next-button"  value="立即注册">
		</div>
	</div>
</div>
<script type="text/javascript">

var Products=
	[
	<#list goodsSpace.productList as product>	
	  {'product_id':${product.product_id},'goods_id' :${product.goods_id},'sn':'${product.sn}','store':${product.store!0},
		'price':${product.price},
	   'specs':${product.specsvIdJson}
	  }
	  <#if product_has_next >,</#if>
	</#list>
	];

$(function() {
    Eop.Spec.init(1);
    $("#insuranceNow").click(function(){
        var isLogin = $("#isLogin").val()
        if(isLogin=="false"){
            showIsLogin()
			return
		}
        var monthnumber = $("input[name='specs']").val()
        var specs = monthnumber.substr(0,1)
        if(specs=="一"){
            specs = 12
        }
        var num = $("input[name='num']").val()
        var goodsid = $("#gooid").val();
        var str = "insyrance.html"
        str += "?"
        str += "goodsid=" + goodsid
        str += "&num=" + num
        str += "&specs=" + specs
        window.location.href =str
	})
})

function showIsLogin() {
    var html = $("#login_tip").html();
    $.dialog({
        title: '提示信息', content: html, lock: true, init: function () {
            $(".button-wrapper .btn").jbtn();
            $(".button-wrapper .to-login-btn").click(function () {
                location.href = "login.html?forward=checkout.html";
            });

            //
            $(".button-wrapper .to-checkout-btn").click(function () {
                location.href = "register.html?forward=checkout.html";
            });
        }
    });
}
</script>